package day11.KeJian;

import java.util.ArrayList;
import java.util.List;

public class MyStream1 {
    public static void main(String[] args) {
        ////集合的批量添加
        ArrayList<String> list1 = new ArrayList<>(List.of("张三丰", "张翠山", "张无忌", "王二麻子", "张良", "谢广坤"));
        //list.add()

        //遍历list1把以张开头的元素添加到list2中。
        ArrayList<String> list2 = new ArrayList<>();
        for (String s : list1) {
            if (s.startsWith("张")){
                list2.add(s);
        }
    }
        ArrayList<String> list3 = new ArrayList<>();
        for (String s1 : list2) {
            if (s1.length() == 3) {
                list3.add(s1);
            }
        }
            for (String s : list3) {
                System.out.println(s);
            }
    }
}